package com.card323.crpg.battle;

import java.awt.Color;

import com.card323.crpg.Hero;

public class BattleTurn implements Runnable {
	BattleEngine _battle;

	public BattleTurn(BattleEngine battle) {
		_battle = battle;
	}

	public void turn_start(int turn, Hero h) {

		h.send_message("回合" + turn, Color.GREEN);
		ActionPoint before = h.get_bi().get_ap().clone();
		h.get_bi().get_ap().add_action_point(h._action_speed);
		h.send_message(before.toString() + " -> " + h.get_bi().get_ap());
		synchronized (h.get_bi()) {
			h.get_bi().buff_update();
		}

	}

	public void run() {

		int i = 1;
		while (!_battle._is_end) {

			for (Hero h : _battle._team1._heros) {
				turn_start(i, h);
			}
			for (Hero h : _battle._team2._heros) {
				turn_start(i, h);
			}

			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			i++;
		}

	}

}
